全部文档

7.2Modbus物模型

为Modbus协议产品提供Modbus协议相关属性的增删改查功能

7.2.1根据ID查询Modbus功能

功能描述:指定产品,获取该产品下某个Modbus功能信息。

GET  /api/v1/products/{productId}/properties/modbus/{id}

Path:

Name Type Description Required
id string Modbus功能ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/modbus/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus功能属性ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10"
scalingfactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": {
        "id": 78,
        "name": "cmd_123",
        "identifier": "prop_2345",
        "accessMode": 1,
        "type": 2,
        "unit": "23we",
        "minimum": 10,
        "maximum": 20,
        "minString": null,
        "maxString": null,
        "productId": 1008764,
        "userId": "w3eec42ceb4c597a3ce7f0b",
        "nodeName": null,
        "readFlag": "",
        "writeFlag": "",
        "scalingfactor": 2.0,
        "swapByte": 0,
        "swapOrder": 0,
        "reportMethod": "time",
        "registerAddress": "0x000",
        "registerNumber": 2
    }
}

7.2.2根据Modbus产品ID查询所有功能

功能描述:指定产品,获取该产品下所有Modbus功能信息。

GET  /api/v1/products/{productId}/properties/modbus

Path:

Name Type Description Required
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/modbus?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus功能属性ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10"
scalingfactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": [
        {
                    "id": 18,
                    "name": "sd_123",
                    "identifier": "ws_2345",
                    "accessMode": 1,
                    "type": 2,
                    "unit": "2wsss",
                    "minimum": 10,
                    "maximum": 20,
                    "minString": null,
                    "maxString": null,
                    "productId": 10023,
                    "userId": "eec42ceb4c597a3ce7f0b",
                    "nodeName": null,
                    "readFlag": "",
                    "writeFlag": "",
                    "scalingfactor": 2.0,
                    "swapByte": 0,
                    "swapOrder": 0,
                    "reportMethod": "time",
                    "registerAddress": "0x000",
                    "registerNumber": 2
        },
        {
                    "id": 28,
                    "name": "cww_123",
                    "identifier": "pww_2345",
                    "accessMode": 1,
                    "type": 2,
                    "unit": "22w3e",
                    "minimum": 10,
                    "maximum": 20,
                    "minString": null,
                    "maxString": null,
                    "productId": 1008764,
                    "userId": "qws3w3c42ceb4c597a3ce7f0b",
                    "nodeName": null,
                    "readFlag": "",
                    "writeFlag": "",
                    "scalingfactor": 3.0,
                    "swapByte": 0,
                    "swapOrder": 0,
                    "reportMethod": "time",
                    "registerAddress": "0x000",
                    "registerNumber": 2
        }
    ]
}

7.2.3新增Modbus物模型草稿

功能描述:指定产品,为该产品添加Modbus物模型草稿,用于读写产品属性值。返回物模型草稿的ID。

POST  /api/v1/products/{productId}/properties/draft/modbus

Path:

Name Type Description Required
productId string 产品ID Yes

Body:

Name Type Description Required
name string 功能名称 Yes
identifier string 属性名称(该产品下唯一) Yes
unit string 属性单位 No
minimum number 参数最小值(数值类型特有) No,type为数值类型必填
maximum number 参数最大值(数值类型特有) No,type为数值类型必填
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04" Yes
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10" No
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
Yes
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。 No
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。 No
scalingfactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。 Yes
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值 No
class int 属性种类 1: 属性, 2: 事件 Yes
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff Yes
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。 原始数据类型为string类型时必填
originDataType int 原始数据类型,数据类型值请参考类型码表。 No
special struct 对部分数据类型的补充说明 No(string/bytes/float32/float64/boolean/enum时必传)

参数originDataType类型码表:

string boolean int8 int16 int32 int64 uint8 uint16 uint32 uint64 float32 float64
1 2 3 4 5 6 7 8 9 10 11 12

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
    "name":"prop_api_modbus_01",
    "identifier":"prop_api_modbus_01",
    "readFlag":"0x03",
    "writeFlag":"0x06",
    "type":1,
    "unit": "C",
    "reportMethod":1,
    "registerAddress":"0x0",
    "swapByte":1,
    "swapOrder" :1,
    "scalingfactor":2.0,
    "registerNumber":2,
    "class":1,
    "originDataType":1,
    "special":{
    "step":20
    }
}

cURL example:

curl --location --request POST '{{address}}/api/v1/products/100086/properties/draft/modbus?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                "name":"prop_api_modbus_01",
                "identifier":"prop_api_modbus_01",
                "readFlag":"0x03",
                "writeFlag":"0x06",
                "type":1,
                "unit": "C",
                "reportMethod":1,
                "registerAddress":"0x0",
                "swapByte":1,
                "swapOrder" :1,
                "scalingFactor":2.0,
                "registerNumber":2,
                "class":1,
                "originDataType":1,
                "special":{
                "step":20
                }
            }'

Response body:

Name Type Description
id int Modbus物模型草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10"
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。
scalingFactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。
productId number 产品ID
userId string 用户ID

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 55,
    "name": "prop_api_modbus_01",
    "identifier": "prop_api_modbus_01",
    "unit": "C",
    "readFlag": "0x03",
    "writeFlag": "0x06",
    "type": 13,
    "swapByte": 1,
    "swapOrder": 1,
    "scalingfactor": 2.0,
    "reportMethod": 1,
    "registerAddress": "0x000",
    "registerNumber": 0,
    "productId": 100150,
    "userId": "a881f626c8ec42ceb4c597a3ce7f0bbe"
  }
}

7.2.4删除Modbus物模型草稿

功能描述:指定产品,删除该产品下某个Modbus物模型草稿。

DELETE  /api/v1/products/{productId}/properties/draft/modbus/{id}

Path:

Name Type Description Required
id string Modbus物模型草稿ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request DELETE '{{address}}/api/v1/products/{productId}/properties/draft/modbus/100086?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
    "success": true,
    "code": 0,
    "msg": ""
}

7.2.5更新Modbus物模型草稿

功能描述:指定产品,修改指定的Modbus物模型草稿。

PUT  /api/v1/products/{productId}/properties/draft/modbus/{id}

Path:

Name Type Description Required
id string Modbus物模型草稿ID Yes
productId string 产品ID Yes

Body:

Name Type Description Required
name string 功能名称 No
unit string 属性单位 No
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"。 No
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10" No
minimum number 参数最小值(数值类型特有) No
maximum number 参数最大值(数值类型特有) No
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。该字段仅对type为数值类型有效。 No
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。该字段仅对type为数值类型有效。 No
scalingfactor double 缩放因子。此字段只有type为数值类型有效。有效值不能为0。 No
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值 No
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff No
special struct 对部分数据类型的补充说明 No

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
    "name":"prop_api_modbus_01u",
    "unit": "C",
    "reportMethod":"time",
    "RegisterAddress":"0x0",
    "swapByte":0,
    "swapOrder" :0,
    "registerNumber":2
}

cURL example:

curl --location --request PUT '{{address}}/api/v1/products/100081/properties/draft/modbus/100086?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"prop_api_modbus_01u",
    "unit": "C",
    "reportMethod":"time",
    "RegisterAddress":"0x0",
    "swapByte":0,
    "swapOrder" :0,
    "registerNumber":2
}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

7.2.6根据ID查询Modbus物模型草稿

功能描述:指定产品,获取该产品下某个Modbus物模型草稿。

GET  /api/v1/products/{productId}/properties/draft/modbus/{id}

Path:

Name Type Description Required
id string Modbus物模型草稿ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/draft/modbus/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus物模型草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10"
scalingfactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": {
        "id": 78,
        "name": "cmd_123",
        "identifier": "prop_2345",
        "accessMode": 1,
        "type": 2,
        "unit": "23we",
        "minimum": 10,
        "maximum": 20,
        "minString": null,
        "maxString": null,
        "productId": 1008764,
        "userId": "w3eec42ceb4c597a3ce7f0b",
        "nodeName": null,
        "readFlag": "",
        "writeFlag": "",
        "scalingfactor": 2.0,
        "swapByte": 0,
        "swapOrder": 0,
        "reportMethod": "time",
        "registerAddress": "0x000",
        "registerNumber": 2
    }
}

7.2.7根据Modbus产品ID查询物模型草稿

功能描述:指定产品,获取该产品下所有Modbus物模型草稿。

GET  /api/v1/products/{productId}/properties/draft/modbus

Path:

Name Type Description Required
id string Modbus功能ID Yes
productId string 产品ID Yes

cURL example:

curl --location --request GET '{{address}}/api/v1/products/{productId}/properties/modbus?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response body:

Name Type Description
id int Modbus物模型草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
unit string 属性单位
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,数据类型值请参考公共能力type类型码表,
当读命令码为"0x01"(线圈状态),"0x02"(离散输入变量)时该参数值只能为bool,不传则默认为bool。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId number 产品ID
userId string 用户ID
nodeName String 节点名称
readFlag string 读命令码,16进制值,支持值选项: 线圈状态 "0x01"; 离散输入变量 "0x02"; 保持寄存器 "0x03"; 输入寄存器 "0x04"
writeFlag string 写命令码,16进制值,支持值选项:线圈状态 "0x05" ,"0x0F"; 保持寄存器 "0x06" ,"0x10"
scalingfactor double 缩放因子,此字段只有type为数值类型有效,默认为1.0。有效值不能为0。
swapByte int 是否交换高低字节(不变:0;变:1),把寄存器内16位数据的前后8个bits互换。默认为0。该字段仅对type为数值类型有效。其他类型将设置为1。
swapOrder int 是否交换顺序(不变:0;变:1),把原始数据32位数据的bits互换。默认为1。该字段仅对type为数值类型有效。其他类型将设置为0。
reportMethod int 上报方式,目前只支持按时上报,值 1 : time, 默认为该值
registerAddress string 寄存器起始地址,16进制值,范围0x0000~0xffff
registerNumber int 寄存器个数,用于确定string类型的数据占用长度。只有type为string时该数据有效。

Response example:

{
    "success": true,
    "code": 0,
    "msg": "",
    "data": [
        {
                    "id": 18,
                    "name": "sd_123",
                    "identifier": "ws_2345",
                    "accessMode": 1,
                    "type": 2,
                    "unit": "2wsss",
                    "minimum": 10,
                    "maximum": 20,
                    "minString": null,
                    "maxString": null,
                    "productId": 10023,
                    "userId": "eec42ceb4c597a3ce7f0b",
                    "nodeName": null,
                    "readFlag": "",
                    "writeFlag": "",
                    "scalingfactor": 2.0,
                    "swapByte": 0,
                    "swapOrder": 0,
                    "reportMethod": "time",
                    "registerAddress": "0x000",
                    "registerNumber": 2
        },
        {
                    "id": 28,
                    "name": "cww_123",
                    "identifier": "pww_2345",
                    "accessMode": 1,
                    "type": 2,
                    "unit": "22w3e",
                    "minimum": 10,
                    "maximum": 20,
                    "minString": null,
                    "maxString": null,
                    "productId": 1008764,
                    "userId": "qws3w3c42ceb4c597a3ce7f0b",
                    "nodeName": null,
                    "readFlag": "",
                    "writeFlag": "",
                    "scalingfactor": 3.0,
                    "swapByte": 0,
                    "swapOrder": 0,
                    "reportMethod": "time",
                    "registerAddress": "0x000",
                    "registerNumber": 2
        }
    ]
}

7.2.8发布Modbus物模型草稿

功能描述:指定物联网平台产品,发布该产品的物模型草稿。

POST  /api/v1/products/{productId}/properties/draft/modbus/publish

Path:

Name Type Description
productId string 产品ID

cURL example:

curl --location --request POST '{{address}}/api/v1/products/{productId}/properties/draft/modbus/publish?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
    "success": true,
    "code": 0,
    "msg": ""
}

results matching ""

    No results matching ""